package com.jbyu.db;

import java.sql.*;


public class DBHelp {
	
	
	
	public static Connection con;
	public static String url ;
	public static String  driverClassName;
	public static String userName;
	public static String password;



	public static Connection getCon() {
		if (con != null) {
			return con;
		}
		try {
			Class.forName(DBHelp.driverClassName);
			con = DriverManager.getConnection(url, userName, password);
		} catch (Exception e) {
			throw new RuntimeException("get connection error");
		}
		return con;
	}

	public static void closeAll(Connection con, Statement statement,
			ResultSet set) {
		try {
			if (set != null) {
				set.close();
			}
			if (statement != null) {
				statement.close();
			}
			if (con != null) {
				//con.close();
			}
		} catch (Exception e) {
			throw new RuntimeException("close connection error");
		}

	}
}
